#ifndef PEOPLETREEMODEL_H
#define PEOPLETREEMODEL_H

#include <QAbstractItemModel>
#include "peopletreenode.h"

class PeopleTreeModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit PeopleTreeModel(QObject *parent = 0);
    ~PeopleTreeModel();

    QModelIndex index(int row, int column, const QModelIndex &parent) const;
    QModelIndex parent(const QModelIndex &child) const;
    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;
    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

    void setRootNode(PeopleTreeNode* newRootNode);
    
signals:
    
public slots:

private:
    void load();
    PeopleTreeNode* nodeFromIndex(const QModelIndex &index) const;

    PeopleTreeNode* m_rootNode;
    QHash<int, PeopleTreeNode *> m_groups; // id - group
};

#endif // PEOPLETREEMODEL_H
